package com.dfec.water.dao;

import com.dfec.framework.mybatis.core.mapper.BaseMapperX;
import com.dfec.framework.mybatis.core.page.PageParam;
import com.dfec.framework.mybatis.core.page.PageUtils;
import com.dfec.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.dfec.water.entity.YdbAreaBaseInfoEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 区域选择Dao接口
 *
 * @author trg
 * @date Thu Jan 09 10:57:17 CST 2025
 */
@Mapper
public interface YdbAreaBaseInfoDao extends BaseMapperX<YdbAreaBaseInfoEntity> {

    /**
     * description:分页查询
     *
     * @param pageParam 分页参数
     * @return
     * @author trg
     * @date 2023/6/27 15:56
     */
    default PageUtils selectPage(PageParam<YdbAreaBaseInfoEntity> pageParam) {
            YdbAreaBaseInfoEntity entity = pageParam.getEntity() == null ? new YdbAreaBaseInfoEntity() :pageParam.getEntity();
        return this.selectPage(pageParam, dealParams(entity));
    }


    /**
     * 不带分页查询
     * @param ydbAreaBaseInfoEntity
     * @return
     */
    default  List<YdbAreaBaseInfoEntity> selectAll(YdbAreaBaseInfoEntity ydbAreaBaseInfoEntity){
        return this.selectList(dealParams(ydbAreaBaseInfoEntity));
    }

    /**
    * description:查询条件拼接
    *
    * @param entity 参数
    * @return
    * @author trg
    * @date 2023/6/27 15:56
    */
    public default LambdaQueryWrapperX<YdbAreaBaseInfoEntity> dealParams(YdbAreaBaseInfoEntity entity){
        return new LambdaQueryWrapperX<YdbAreaBaseInfoEntity>()
                        .likeIfPresent(YdbAreaBaseInfoEntity::getAreaName, entity.getAreaName())
                            .eqIfPresent(YdbAreaBaseInfoEntity::getAreaDesc, entity.getAreaDesc())
                            .eqIfPresent(YdbAreaBaseInfoEntity::getAreaJson, entity.getAreaJson())
        ;
    }


   List<Map<Object,Object>> selectTableInfo(@Param("tableName") String tableName);


}
